#!/bin/bash

#  Copyright (C) 2013 Curt Brune <curt@cumulusnetworks.com>
#  Copyright (C) 2016 Pankaj Bansal <pankajbansal3073@gmail.com>
#
#  SPDX-License-Identifier:     GPL-2.0

SERIES="$1"
SRC="$2"

if [ -z "$SERIES" -o -z "$SRC" -o ! -f "$SERIES" -o ! -d "$SRC" ]; then
    echo "Usage: $0 /path/to/series /path/to/source"
    exit 100
fi

SERIES="`realpath \"$SERIES\"`"
PATCH_ROOT=`dirname $SERIES`

cd "$SRC" &&
git init && 
git add . > /dev/null &&
git commit -m "Unmodified $(basename $SRC) src" --allow-empty > /dev/null &&
stg init && 
stg import -s "$SERIES" &&
echo -e "%(description)s\n" > .git/patchexport.tmpl
